package com.ss.android.article.base.feature.update.b;

import com.ss.android.article.base.feature.update.a.d;
import com.ss.android.article.base.feature.update.a.e;
import com.ss.android.common.load.AsyncLoader.LoaderProxy;

import java.util.Iterator;

final class p implements LoaderProxy {
    private final UpdateItemMgr a;

    p(UpdateItemMgr arg1) {
        this.a = arg1;

    }

    public final Object doInBackground(Object key, Object param, Object extra) {
        d v0;
        long v4 = 0;
        d v1 = null;
        if (key == null || ((Long) key).longValue() <= v4) {
            v0 = v1;
        } else {
            v0 = UpdateItemMgr.a(((Long) key).longValue(), v1, ((Integer) param).intValue());
            if (v0 != null && v0.r > v4) {
                return v0;
            }

            v0 = v1;
        }

        return v0;
    }

    public final void onLoaded(Object key, Object param, Object extra, Object result) {
        long v4 = 0;
        UpdateItemMgr v6 = this.a;
        long v2 = key != null ? ((Long) key).longValue() : v4;
        if (v2 > v4) {
            if (result != null && (((d) result).d)) {
                v6.d(v2);
                return;
            }

            e v0 = null;
            e v1 = result != null ? v6.a(((d) result)) : v0;
            if (v1 != null) {
                v1.a.r = System.currentTimeMillis();
                v6.b((d) v1.a);
            }

            Iterator v4_1 = v6.d.iterator();
            while (v4_1.hasNext()) {
                Object v0_1 = v4_1.next();
                if (v0_1 == null) {
                    continue;
                }

                ((UpdateItemMgr.o$a) v0_1).a(v2, v1);
            }
        }
    }
}

